<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="90px"
    >
      <el-form-item label="进出仓单号" prop="warehouseDocumentNumber">
        <el-input
          v-model="queryParams.warehouseDocumentNumber"
          placeholder="请输入进出仓单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="进出仓日期" prop="inventoryDate">
        <el-date-picker
          clearable
          v-model="queryParams.inventoryDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择进出仓日期"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item label="商品编码" prop="productCode">
        <el-input
          v-model="queryParams.productCode"
          placeholder="请输入商品编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="款式编码" prop="styleCode">
        <el-input
          v-model="queryParams.styleCode"
          placeholder="请输入款式编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
        <el-button
          :icon="!isOpen ? 'el-icon-arrow-down' : 'el-icon-arrow-up'"
          size="mini"
          @click="shouqi"
          >展开/收起</el-button
        >
      </el-form-item>

      <div v-if="isOpen">
        <el-form-item label="关联单号" prop="relatedOrderNumber">
          <el-input
            v-model="queryParams.relatedOrderNumber"
            placeholder="请输入关联单号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="创建人" prop="creator">
          <el-input
            v-model="queryParams.creator"
            placeholder="请输入创建人"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>

        <el-form-item label="历史成本价" prop="historicalCostPrice">
          <el-input
            v-model="queryParams.historicalCostPrice"
            placeholder="请输入历史成本价"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="商品标签" prop="productTag">
          <el-input
            v-model="queryParams.productTag"
            placeholder="请输入商品标签"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="颜色规格" prop="colorSpecification">
          <el-input
            v-model="queryParams.colorSpecification"
            placeholder="请输入颜色规格"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="分类" prop="category">
          <el-input
            v-model="queryParams.category"
            placeholder="请输入分类"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="虚拟分类" prop="virtualCategory">
          <el-input
            v-model="queryParams.virtualCategory"
            placeholder="请输入虚拟分类"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="供应商" prop="supplierName">
          <el-input
            v-model="queryParams.supplierName"
            placeholder="请输入供应商"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="单据供应商" prop="documentSupplier">
          <el-input
            v-model="queryParams.documentSupplier"
            placeholder="请输入单据供应商"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="供应商款号" prop="supplierId">
          <el-input
            v-model="queryParams.supplierId"
            placeholder="请输入供应商款号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="供应商商品编码" prop="supplierProductCode">
          <el-input
            v-model="queryParams.supplierProductCode"
            placeholder="请输入供应商商品编码"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="品牌" prop="brand">
          <el-input
            v-model="queryParams.brand"
            placeholder="请输入品牌"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="重量" prop="weight">
          <el-input
            v-model="queryParams.weight"
            placeholder="请输入重量"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="体积" prop="volume">
          <el-input
            v-model="queryParams.volume"
            placeholder="请输入体积"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="长" prop="length">
          <el-input
            v-model="queryParams.length"
            placeholder="请输入长"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="宽" prop="width">
          <el-input
            v-model="queryParams.width"
            placeholder="请输入宽"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="高" prop="height">
          <el-input
            v-model="queryParams.height"
            placeholder="请输入高"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="仓储方" prop="warehouseSide">
          <el-input
            v-model="queryParams.warehouseSide"
            placeholder="请输入仓储方"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="仓库" prop="warehouse">
          <el-input
            v-model="queryParams.warehouse"
            placeholder="请输入仓库"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="数量" prop="quantityCount">
          <el-input
            v-model="queryParams.quantityCount"
            placeholder="请输入数量"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="单位" prop="unit">
          <el-input
            v-model="queryParams.unit"
            placeholder="请输入单位"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="关联仓库" prop="relatedWarehouse">
          <el-input
            v-model="queryParams.relatedWarehouse"
            placeholder="请输入关联仓库"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="明细行备注" prop="detailRowNote">
          <el-input
            v-model="queryParams.detailRowNote"
            placeholder="请输入明细行备注"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="原始线上订单号" prop="originalOrderId">
          <el-input
            v-model="queryParams.originalOrderId"
            placeholder="请输入原始线上订单号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="店铺名称" prop="storeName">
          <el-input
            v-model="queryParams.storeName"
            placeholder="请输入店铺名称"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="售后单号" prop="saleOrderNumber">
          <el-input
            v-model="queryParams.saleOrderNumber"
            placeholder="请输入售后单号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="线上订单号" prop="orderId">
          <el-input
            v-model="queryParams.orderId"
            placeholder="请输入线上订单号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="单据标签" prop="documentLabel">
          <el-input
            v-model="queryParams.documentLabel"
            placeholder="请输入单据标签"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="快递单号" prop="trackingNumber">
          <el-input
            v-model="queryParams.trackingNumber"
            placeholder="请输入快递单号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
      </div>
      <!-- <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item> -->
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['JstOrigSalesOutbound:jst:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['JstOrigSalesOutbound:jst:edit']"
          >修改</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['JstOrigSalesOutbound:jst:remove']"
          >删除</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['JstOrigSalesOutbound:jst:export']"
          >导出</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-upload
          ref="daoru"
          :action="Upload.url"
          :headers="Upload.headers"
          :limit="limit"
          :on-exceed="handleExceed"
          :on-success="handlePictureSuccessPic"
          :before-upload="beforeAvatarUpload"
          :file-list="fileLi"
          :on-change="changeFile1"
        >
          <el-button size="mini" plain icon="el-icon-upload"
            >批量导入</el-button
          >

          <!-- <i class="el-icon-plus"></i> -->
        </el-upload>
        <!-- <el-button size="mini" plain icon="el-icon-upload" @click="daoru"
          >导入成本</el-button
        > -->
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="jstList"
      @selection-change="handleSelectionChange"
      :height="620"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="id" align="center" prop="id" />
      <el-table-column
        label="进出仓单号"
        align="center"
        prop="warehouseDocumentNumber"
      />
      <el-table-column
        label="关联单号"
        align="center"
        prop="relatedOrderNumber"
      />
      <el-table-column
        label="进出仓日期"
        align="center"
        prop="inventoryDate"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.inventoryDate, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column label="创建人" align="center" prop="creator" />
      <el-table-column label="商品编码" align="center" prop="productCode" />
      <el-table-column label="款式编码" align="center" prop="styleCode" />
      <el-table-column
        label="历史成本价"
        align="center"
        prop="historicalCostPrice"
      />
      <el-table-column label="商品标签" align="center" prop="productTag" />
      <el-table-column
        label="颜色规格"
        align="center"
        prop="colorSpecification"
      />
      <el-table-column label="分类" align="center" prop="category" />
      <el-table-column label="虚拟分类" align="center" prop="virtualCategory" />
      <el-table-column label="供应商" align="center" prop="supplierName" />
      <el-table-column
        label="单据供应商"
        align="center"
        prop="documentSupplier"
      />
      <el-table-column label="供应商款号" align="center" prop="supplierId" />
      <el-table-column
        label="供应商商品编码"
        align="center"
        prop="supplierProductCode"
      />
      <el-table-column label="品牌" align="center" prop="brand" />
      <el-table-column label="重量" align="center" prop="weight" />
      <el-table-column label="体积" align="center" prop="volume" />
      <el-table-column label="长" align="center" prop="length" />
      <el-table-column label="宽" align="center" prop="width" />
      <el-table-column label="高" align="center" prop="height" />
      <el-table-column label="进出仓类型" align="center" prop="storageType" />
      <el-table-column label="仓储方" align="center" prop="warehouseSide" />
      <el-table-column label="仓库" align="center" prop="warehouse" />
      <el-table-column label="数量" align="center" prop="quantityCount" />
      <el-table-column label="单位" align="center" prop="unit" />
      <el-table-column
        label="关联仓库"
        align="center"
        prop="relatedWarehouse"
      />
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="明细行备注" align="center" prop="detailRowNote" />
      <el-table-column
        label="原始线上订单号"
        align="center"
        prop="originalOrderId"
      />
      <el-table-column label="店铺名称" align="center" prop="storeName" />
      <el-table-column label="售后单号" align="center" prop="saleOrderNumber" />
      <el-table-column label="线上订单号" align="center" prop="orderId" />
      <el-table-column label="出仓类型" align="center" prop="warehouseType" />
      <el-table-column label="单据标签" align="center" prop="documentLabel" />
      <el-table-column label="快递单号" align="center" prop="trackingNumber" />
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['JstOrigSalesOutbound:jst:edit']"
            >修改</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['JstOrigSalesOutbound:jst:remove']"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改聚水潭原始销售出库对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="进出仓单号" prop="warehouseDocumentNumber">
          <el-input
            v-model="form.warehouseDocumentNumber"
            placeholder="请输入进出仓单号"
          />
        </el-form-item>
        <el-form-item label="关联单号" prop="relatedOrderNumber">
          <el-input
            v-model="form.relatedOrderNumber"
            placeholder="请输入关联单号"
          />
        </el-form-item>
        <el-form-item label="进出仓日期" prop="inventoryDate">
          <el-date-picker
            clearable
            v-model="form.inventoryDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择进出仓日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="创建人" prop="creator">
          <el-input v-model="form.creator" placeholder="请输入创建人" />
        </el-form-item>
        <el-form-item label="商品编码" prop="productCode">
          <el-input v-model="form.productCode" placeholder="请输入商品编码" />
        </el-form-item>
        <el-form-item label="款式编码" prop="styleCode">
          <el-input v-model="form.styleCode" placeholder="请输入款式编码" />
        </el-form-item>
        <el-form-item label="历史成本价" prop="historicalCostPrice">
          <el-input
            v-model="form.historicalCostPrice"
            placeholder="请输入历史成本价"
          />
        </el-form-item>
        <el-form-item label="商品标签" prop="productTag">
          <el-input v-model="form.productTag" placeholder="请输入商品标签" />
        </el-form-item>
        <el-form-item label="颜色规格" prop="colorSpecification">
          <el-input
            v-model="form.colorSpecification"
            placeholder="请输入颜色规格"
          />
        </el-form-item>
        <el-form-item label="分类" prop="category">
          <el-input v-model="form.category" placeholder="请输入分类" />
        </el-form-item>
        <el-form-item label="虚拟分类" prop="virtualCategory">
          <el-input
            v-model="form.virtualCategory"
            placeholder="请输入虚拟分类"
          />
        </el-form-item>
        <el-form-item label="供应商" prop="supplierName">
          <el-input v-model="form.supplierName" placeholder="请输入供应商" />
        </el-form-item>
        <el-form-item label="单据供应商" prop="documentSupplier">
          <el-input
            v-model="form.documentSupplier"
            placeholder="请输入单据供应商"
          />
        </el-form-item>
        <el-form-item label="供应商款号" prop="supplierId">
          <el-input v-model="form.supplierId" placeholder="请输入供应商款号" />
        </el-form-item>
        <el-form-item label="供应商商品编码" prop="supplierProductCode">
          <el-input
            v-model="form.supplierProductCode"
            placeholder="请输入供应商商品编码"
          />
        </el-form-item>
        <el-form-item label="品牌" prop="brand">
          <el-input v-model="form.brand" placeholder="请输入品牌" />
        </el-form-item>
        <el-form-item label="重量" prop="weight">
          <el-input v-model="form.weight" placeholder="请输入重量" />
        </el-form-item>
        <el-form-item label="体积" prop="volume">
          <el-input v-model="form.volume" placeholder="请输入体积" />
        </el-form-item>
        <el-form-item label="长" prop="length">
          <el-input v-model="form.length" placeholder="请输入长" />
        </el-form-item>
        <el-form-item label="宽" prop="width">
          <el-input v-model="form.width" placeholder="请输入宽" />
        </el-form-item>
        <el-form-item label="高" prop="height">
          <el-input v-model="form.height" placeholder="请输入高" />
        </el-form-item>
        <el-form-item label="仓储方" prop="warehouseSide">
          <el-input v-model="form.warehouseSide" placeholder="请输入仓储方" />
        </el-form-item>
        <el-form-item label="仓库" prop="warehouse">
          <el-input v-model="form.warehouse" placeholder="请输入仓库" />
        </el-form-item>
        <el-form-item label="数量" prop="quantityCount">
          <el-input v-model="form.quantityCount" placeholder="请输入数量" />
        </el-form-item>
        <el-form-item label="单位" prop="unit">
          <el-input v-model="form.unit" placeholder="请输入单位" />
        </el-form-item>
        <el-form-item label="关联仓库" prop="relatedWarehouse">
          <el-input
            v-model="form.relatedWarehouse"
            placeholder="请输入关联仓库"
          />
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" placeholder="请输入备注" />
        </el-form-item>
        <el-form-item label="明细行备注" prop="detailRowNote">
          <el-input
            v-model="form.detailRowNote"
            placeholder="请输入明细行备注"
          />
        </el-form-item>
        <el-form-item label="原始线上订单号" prop="originalOrderId">
          <el-input
            v-model="form.originalOrderId"
            placeholder="请输入原始线上订单号"
          />
        </el-form-item>
        <el-form-item label="店铺名称" prop="storeName">
          <el-input v-model="form.storeName" placeholder="请输入店铺名称" />
        </el-form-item>
        <el-form-item label="售后单号" prop="saleOrderNumber">
          <el-input
            v-model="form.saleOrderNumber"
            placeholder="请输入售后单号"
          />
        </el-form-item>
        <el-form-item label="线上订单号" prop="orderId">
          <el-input v-model="form.orderId" placeholder="请输入线上订单号" />
        </el-form-item>
        <el-form-item label="单据标签" prop="documentLabel">
          <el-input v-model="form.documentLabel" placeholder="请输入单据标签" />
        </el-form-item>
        <el-form-item label="快递单号" prop="trackingNumber">
          <el-input
            v-model="form.trackingNumber"
            placeholder="请输入快递单号"
          />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
//--------导入token
import { getToken } from "@/utils/auth";
import {
  listJst,
  getJst,
  delJst,
  addJst,
  updateJst,
} from "@/api/JstOrigSalesOutbound/jst";

export default {
  name: "Jst",
  data() {
    return {
      fileLi: [],
      dialogVisible: false,
      limit: 2,
      Upload: {
        // 设置上传的请求头部
        headers: {
          header: { responseType: "blob" },

          Authorization: "Bearer " + getToken(),
        },
        // 图片上传的方法地址:
        url:
          process.env.VUE_APP_BASE_API + "/JstOrigSalesOutbound/jst/importData",
      },
      isOpen: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 聚水潭原始销售出库表格数据
      jstList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        warehouseDocumentNumber: null,
        relatedOrderNumber: null,
        inventoryDate: null,
        creator: null,
        productCode: null,
        styleCode: null,
        historicalCostPrice: null,
        productTag: null,
        colorSpecification: null,
        category: null,
        virtualCategory: null,
        supplierName: null,
        documentSupplier: null,
        supplierId: null,
        supplierProductCode: null,
        brand: null,
        weight: null,
        volume: null,
        length: null,
        width: null,
        height: null,
        storageType: null,
        warehouseSide: null,
        warehouse: null,
        quantityCount: null,
        unit: null,
        relatedWarehouse: null,
        detailRowNote: null,
        originalOrderId: null,
        storeName: null,
        saleOrderNumber: null,
        orderId: null,
        warehouseType: null,
        documentLabel: null,
        trackingNumber: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
    };
  },
  created() {
    this.getList();
  },
  methods: {
    //搜索栏展示与收起
    shouqi() {
      // console.log(1);
      this.isOpen = !this.isOpen;
    },
    /** 查询聚水潭原始销售出库列表 */
    getList() {
      this.loading = true;
      listJst(this.queryParams).then((response) => {
        this.jstList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        warehouseDocumentNumber: null,
        relatedOrderNumber: null,
        inventoryDate: null,
        creator: null,
        productCode: null,
        styleCode: null,
        historicalCostPrice: null,
        productTag: null,
        colorSpecification: null,
        category: null,
        virtualCategory: null,
        supplierName: null,
        documentSupplier: null,
        supplierId: null,
        supplierProductCode: null,
        brand: null,
        weight: null,
        volume: null,
        length: null,
        width: null,
        height: null,
        storageType: null,
        warehouseSide: null,
        warehouse: null,
        quantityCount: null,
        unit: null,
        relatedWarehouse: null,
        remark: null,
        detailRowNote: null,
        originalOrderId: null,
        storeName: null,
        saleOrderNumber: null,
        orderId: null,
        warehouseType: null,
        documentLabel: null,
        trackingNumber: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加聚水潭原始销售出库";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      getJst(id).then((response) => {
        this.form = response.data;
        this.open = true;
        this.title = "修改聚水潭原始销售出库";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.id != null) {
            updateJst(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addJst(this.form).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm('是否确认删除聚水潭原始销售出库编号为"' + ids + '"的数据项？')
        .then(function () {
          return delJst(ids);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "JstOrigSalesOutbound/jst/export",
        {
          ...this.queryParams,
        },
        `jst_${new Date().getTime()}.xlsx`
      );
    },
    //图片上传前的相关判断
    beforeAvatarUpload(file) {
      // const isJPG = file.type == 'image/jpeg' || file.type == 'image/png';
      const isLt2M = file.size / 1024 / 1024 < 100;
      // if (!isJPG) {
      //     this.$message.error('上传头像图片只能是 JPG/PNG 格式!');
      // }
      if (!isLt2M) {
        this.$message.error("上传导入文件大小不能超过 100MB!");
      }
      this.openUploadLoading();
      return isLt2M;
    },
    //图片预览
    handlePictureCardPreview(file) {
      this.picUrl = file.url;
      this.imageUrl = file.url;
      // this.dialogVisible = true;
    },
    //部门文件导入修改打开
    daoru() {
      this.dialogVisible = true;
    },
    // 打开加载层
    openUploadLoading() {
      this.$modal.loading("正在导入，请稍候！");
    },
    //文件导入成功回传

    handlePictureSuccessPic(response, file) {
      this.$refs.daoru.clearFiles(); //去掉文件列表
      this.$modal.closeLoading();
      console.log(JSON.stringify(file));
      console.log(JSON.stringify(response));
      this.getList();

      // this.dialogVisible = true;
      // this.dialogVisibleList = response;
      // if (response.code == 200) {

      //   this.$modal.msgSuccess("导入成功");
      //   this.getList();
      // }

      // this.openmsg = true;
      // this.msg = response.msg;

      //设置图片访问路径 （url 后台传过来的的上传地址）
      // this.picUrl = file.response.url;
      // const url = file.response.fileName;
      // this.file = file.response.url;
      // console.log(JSON.stringify(this.file));
      // if (res.code == 200) {

      //   this.dialogVisible = false

      //   if (res.msg == '操作成功') {

      //     this.$modal.msgSuccess('导入成功')
      //   } else {
      //     this.$modal.msgError(res.msg);
      //   }
      //   this.getList();
      //   // return true
      // } else {
      //   this.$modal.msgError(res.msg);
      //   this.dialogVisible = true
      //   // this.$message.msgError('该颜色未在字典定义')
      //   return
      // }
    },

    // 文件个数超出
    handleExceed() {
      this.$modal.msgError(`上传链接文件数量不能超过 ${this.limit} 个!`);
    },
    // 上传文件让第二次覆盖第一的文件
    changeFile1(file, fileList) {
      if (fileList.length > 1) {
        this.fileLi = fileList.slice(-1);

        // this.fileList = [fileList[fileList.length - 1]]//这一步，是 展示最后一次选择文件
      }
      // this.fileSpecial = fileList;
    },
  },
};
</script>
